// 2025/9/13
// 删除有序数组中的重复项二

class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        int i = 1, count = 1;
        for(int j = 1; j < nums.size(); j++)
        {
            if(nums[j] == nums[j - 1])
                count++;
            else
                count = 1;

            if(count <= 2)
            {
                nums[i++] = nums[j];
            }
        }
        return i;
    }
};